package org.jeecg.modules.nongjt.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.nongjt.entity.NjtUserPerfect;
import org.jeecg.modules.nongjt.service.INjtUserPerfectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户完善信息 前端控制器
 * </p>
 *
 * @author yaorange
 * @since 2022-06-15
 */
@RestController
@RequestMapping("/user/njtUserPerfect")
public class NjtUserPerfectController {
    @Autowired
    private INjtUserPerfectService njtUserPerfectService;
    @GetMapping("/page")
    private Result<?> getPage(@RequestParam(defaultValue = "1") Integer pageNum,
                              @RequestParam(defaultValue = "5") Integer pageSize,
                              NjtUserPerfect njtUserPerfect){
        Page<NjtUserPerfect> page = new Page<>(pageNum, pageSize);
        QueryWrapper<NjtUserPerfect> queryWrapper = new QueryWrapper<>();
        if (njtUserPerfect != null){
            if (!StringUtils.isEmpty(njtUserPerfect.getCompanyName())){
                queryWrapper.like("company_name",njtUserPerfect.getCompanyName());
            }
            if (!StringUtils.isEmpty(njtUserPerfect.getMobilePhone())){
                queryWrapper.eq("mobile_phone",njtUserPerfect.getMobilePhone());
            }
        }
        njtUserPerfectService.page(page,queryWrapper);
        return Result.ok(page);
    }

}

